<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:of="http://omnifaces.org/functions"
      xmlns:jsf="http://xmlns.jcp.org/jsf">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition template="/dataverse_template.xhtml">
            <ui:param name="pageTitle" value="#{empty DataversePage.dataverse.name ? bundle.new : DataversePage.dataverse.name}"/>
            <ui:param name="dataverse" value="#{DataversePage.dataverse}"/>
            <ui:param name="editModeDataverse" value="#{DataversePage.editMode}"/>
            <ui:define name="meta_header">
            <meta name="description" content="#{MarkupChecker:stripAllTags(DataversePage.dataverse.description)}"/>
            </ui:define>
            <ui:define name="metadata">
                <f:metadata>
                    <f:viewParam name="id" value="#{DataversePage.id}"/>
                    <f:viewParam name="alias" value="#{DataversePage.alias}"/>
                    <f:viewParam name="ownerId" value="#{DataversePage.ownerId}"/>
                    <o:viewParam name="editMode" value="#{DataversePage.editMode}"/>
                    <f:viewAction action="#{dataverseSession.updateLocaleInViewRoot}"/>
                    <f:viewAction action="#{DataversePage.init}"/>
                    <f:viewAction action="#{dataverseHeaderFragment.initBreadcrumbs(DataversePage.dataverse)}"/>
                    <f:viewParam name="alias" value="#{SearchIncludeFragment.dataverseAlias}"/>
                    <f:viewParam name="q" value="#{SearchIncludeFragment.query}"/>
                    <f:viewParam name="types" value="#{SearchIncludeFragment.selectedTypesString}"/>
                    <f:viewParam name="fq1" value="#{SearchIncludeFragment.fq1}"/>
                    <f:viewParam name="fq0" value="#{SearchIncludeFragment.fq0}"/>
                    <f:viewParam name="fq2" value="#{SearchIncludeFragment.fq2}"/>
                    <f:viewParam name="fq3" value="#{SearchIncludeFragment.fq3}"/>
                    <f:viewParam name="fq4" value="#{SearchIncludeFragment.fq4}"/>
                    <f:viewParam name="fq5" value="#{SearchIncludeFragment.fq5}"/>
                    <f:viewParam name="fq6" value="#{SearchIncludeFragment.fq6}"/>
                    <f:viewParam name="fq7" value="#{SearchIncludeFragment.fq7}"/>
                    <f:viewParam name="fq8" value="#{SearchIncludeFragment.fq8}"/>
                    <f:viewParam name="fq9" value="#{SearchIncludeFragment.fq9}"/>
                    <f:viewParam name="sort" value="#{SearchIncludeFragment.sortField}"/>
                    <f:viewParam name="order" value="#{SearchIncludeFragment.sortOrder}"/>
                    <f:viewParam name="page" value="#{SearchIncludeFragment.page}"/>
                    <f:viewParam name="debug" value="#{dataverseSession.debug}"/>
                    <f:viewParam name="adjustFacetName" value="#{SearchIncludeFragment.adjustFacetName}"/>
                    <f:viewParam name="adjustFacetNumber" value="#{SearchIncludeFragment.adjustFacetNumber}"/>
                    <f:viewAction action="#{SearchIncludeFragment.search()}" />
                </f:metadata>
            </ui:define>
            <ui:define name="body">
                <f:loadBundle basename="ValidationMessages" var="valMsg"/>
                <h:form id="dataverseForm">
                    <!-- Edit Mode -->
                    <ui:fragment rendered="#{DataversePage.editMode == 'INFO' or DataversePage.editMode == 'CREATE'}">
                        <p:focus context="dataverseForm"/>
                        <div class="row">
                            <div class="col-xs-6 form-group">
                                <span class="glyphicon glyphicon-asterisk text-danger"/> <h:outputText value="#{bundle['dataset.asterisk.tip']}"/>
                            </div>
                        </div>
                        <!-- Edit Info Panel -->
                        <div class="row" jsf:rendered="#{DataversePage.ownerId != null}">
                            <div class="col-md-6 form-group">
                                <p:outputLabel for="#{DataversePage.editMode == 'CREATE' ? 'selectHostDataverse' : 'hostDataverseStatic'}" styleClass="control-label">
                                    #{bundle.hostDataverse}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.host.title']}"></span>
                                </p:outputLabel>
                                <div class="form-col-container">
                                    <ui:fragment rendered="#{DataversePage.editMode == 'INFO'}">
                                        <p jsf:id="hostDataverseStatic" class="form-control-static">#{DataversePage.dataverse.getOwner().name}</p>
                                        <h:inputHidden value="#{DataversePage.ownerId}" id="hostDataverseStatic_hidden"/>
                                    </ui:fragment>
                                    <p:autoComplete id="selectHostDataverse"
                                                    rendered="#{DataversePage.editMode == 'CREATE'}"
                                                    placeholder="#{bundle['dataverse.link.yourDataverses.inputPlaceholder']}"
                                                    emptyMessage="#{bundle['dataverse.host.autocomplete.nomatches']}"
                                                    scrollHeight="180" forceSelection="true" 
                                                    minQueryLength="1" queryDelay="1000"
                                                    value="#{DataversePage.dataverse.owner}" 
                                                    multiple="false"
                                                    completeMethod="#{DataversePage.completeHostDataverseMenuList}"
                                                    required="#{param['DO_DS_LINK_VALIDATION']}" requiredMessage="#{bundle['dataverse.link.select']}"
                                                    styleClass="DropdownPopup" panelStyleClass="DropdownPopupPanel"
                                                    var="hostDataverse" itemLabel="#{hostDataverse.displayName}" itemValue="#{hostDataverse}" converter="dataverseConverter">
                                        <p:column>
                                            <h:outputText value="#{hostDataverse.displayName}"/> 
                                        </p:column>
                                        <p:column>
                                            <h:outputText value="#{hostDataverse.alias}"/> 
                                        </p:column>
                                        <p:ajax process="@this" event="itemSelect" oncomplete="updateOwnerDataverse()"/>
                                        <p:ajax process="@this" event="itemUnselect" oncomplete="updateOwnerDataverse()"/>
                                    </p:autoComplete>
                                    <p:message for="selectHostDataverse"/>
                                    <p:commandButton id="updateOwnerDataverse"
                                                     style="display:none"
                                                     process="@this :dataverseForm:selectHostDataverse"
                                                     update=":dataverseForm,:breadCrumbPanel"
                                                     action="#{DataversePage.updateOwnerDataverse()}">
                                    </p:commandButton>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 form-group">
                                <h:outputLabel for="name" styleClass="control-label">
                                    #{bundle['dataverse.name']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.name.title']}"></span>
                                </h:outputLabel>
                                <div class="form-col-container">
                                    <p:inputText id="name" styleClass="form-control" 
                                                 value="#{DataversePage.dataverse.name}" required="true" 
                                                 requiredMessage="#{valMsg['dataverse.name']}"/>
                                    <p:message for="name" display="text"/>
                                </div>
                            </div>
                            <div class="col-md-6 form-group">
                                <h:outputLabel for="affiliation" styleClass="control-label">
                                    #{bundle.affiliation}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.affiliation.title']}"></span>
                                </h:outputLabel>
                                <div class="form-col-container">
                                    <p:inputText id="affiliation" styleClass="form-control" value="#{DataversePage.dataverse.affiliation}"/>
                                    <p:message for="affiliation" display="text"/>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 form-group">
                                <h:outputLabel for="identifier" styleClass="control-label">
                                    #{bundle.identifier} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.identifier.title']}"></span>
                                </h:outputLabel>
                                <div class="form-col-container">
                                    <div class="input-group">
                                        <div class="input-group-addon"><span class="small">#{settingsWrapper.dataverseSiteUrl}/dataverse/</span></div>
                                        <p:inputText id="identifier" styleClass="form-control" 
                                                     validator="#{DataversePage.validateAlias}" 
                                                     value="#{DataversePage.dataverse.alias}" 
                                                    required ="true" requiredMessage="#{valMsg['dataverse.alias']}"/>
                                    </div>
                                    <p:message for="identifier" display="text"/>
                                </div>
                            </div>
                            <div class="col-md-6 form-group" jsf:rendered="#{dataverseSession.user.superuser}">
                                <h:outputLabel for="dataverseStorage" styleClass="control-label">
                                    #{bundle.storage} 
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.storage.title']}"></span>
                                </h:outputLabel>
                                <div class="form-col-container">
                                            <h:selectOneMenu id="dataverseStorage" styleClass="form-control" value="#{DataversePage.dataverse.storageDriverId}">
                                              <f:selectItems value="#{DataversePage.getStorageDriverOptions()}" var="driver" itemLabel="#{driver.getKey()}" itemValue="#{driver.getValue()}"/>
                                            </h:selectOneMenu>
                                            <p:message for="dataverseStorage" display="text"/>
                                </div>
                            </div>
                            <div class="col-md-6 form-group" jsf:rendered="#{dataverseSession.user.superuser and DataversePage.getCurationLabelSetOptions().size() >0}">
                                <h:outputLabel for="dataverseCurationLabels" styleClass="control-label">
                                    #{bundle.curationLabels} 
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.curationLabels.title']}"></span>
                                </h:outputLabel>
                                <div class="form-col-container">
                                            <h:selectOneMenu id="dataverseCurationLabels" styleClass="form-control" value="#{DataversePage.dataverse.curationLabelSetName}">
                                              <f:selectItems value="#{DataversePage.getCurationLabelSetOptions()}" var="setName" itemLabel="#{setName.getKey()}" itemValue="#{setName.getValue()}"/>
                                            </h:selectOneMenu>
                                            <p:message for="dataverseCurationLabels" display="text"/>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 form-group">
                                <div class="row">
                                    <div class="col-xs-12 form-group">
                                        <h:outputLabel for="dataverseCategory" styleClass="control-label">
                                            #{bundle['dataverse.category']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.category.title']}"></span>
                                        </h:outputLabel>
                                        <div class="form-col-container">
                                            <h:selectOneMenu id="dataverseCategory" styleClass="form-control" value="#{DataversePage.dataverse.dataverseType}" required="true"
                                                             requiredMessage="#{valMsg['dataverse.category']}">
                                                <f:selectItem id="dvSelect" itemLabel="#{bundle['dataverse.type.selectTab.top']}" itemValue="" />
                                                <f:selectItem id="dvDepartment" itemLabel="#{bundle['dataverse.type.selectTab.department']}" itemValue="DEPARTMENT" />
                                                <f:selectItem id="dvJournals" itemLabel="#{bundle['dataverse.type.selectTab.journals']}" itemValue="JOURNALS" />
                                                <f:selectItem id="dvLab" itemLabel="#{bundle['dataverse.type.selectTab.laboratory']}" itemValue="LABORATORY" />
                                                <f:selectItem id="dvOrgInst" itemLabel="#{bundle['dataverse.type.selectTab.organizationsAndInsitutions']}" itemValue="ORGANIZATIONS_INSTITUTIONS" />
                                                <f:selectItem id="dvResearch" itemLabel="#{bundle['dataverse.type.selectTab.researchers']}" itemValue="RESEARCHERS" />
                                                <f:selectItem id="dvResearchGrp" itemLabel="#{bundle['dataverse.type.selectTab.researchGroup']}" itemValue="RESEARCH_GROUP" />
                                                <f:selectItem id="dvResearchProj" itemLabel="#{bundle['dataverse.type.selectTab.researchProjects']}" itemValue="RESEARCH_PROJECTS" />
                                                <f:selectItem id="dvTeaching" itemLabel="#{bundle['dataverse.type.selectTab.teachingCourses']}" itemValue="TEACHING_COURSES" />
                                                <f:selectItem id="dvUncategorized" itemLabel="#{bundle['dataverse.type.selectTab.uncategorized']}" itemValue="UNCATEGORIZED" />
                                            </h:selectOneMenu>
                                            <p:message for="dataverseCategory" display="text"/>
                                        </div>
                                    </div>
                                    <div class="col-xs-12 form-group">
                                        <p:fragment>
                                            <p:autoUpdate/>
                                            <p:outputLabel id="contactEmailLabel" styleClass="control-label">
                                                #{bundle['dataverse.email']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.email.title']}"></span>
                                            </p:outputLabel>
                                            <div class="form-col-container edit-compound-field">
                                                <ui:repeat value="#{DataversePage.dataverse.dataverseContacts}" var="contacts" varStatus="valCount">
                                                    <div class="row col-xs-12 form-group">
                                                        <div class="col-xs-9 form-col-container">
                                                            <p:inputText id="contactEmail" styleClass="form-control" value="#{contacts.contactEmail}" required="#{param['DO_VALIDATION']}">
                                                                <f:validateBean disabled="#{param['SKIP_VALIDATION']}"/>
                                                                <f:passThroughAttribute name="aria-labelledby" value="dataverseForm:contactEmailLabel"/>
                                                            </p:inputText>
                                                            <p:message for="contactEmail" display="text"/>
                                                        </div>
                                                        <!-- Add / Remove buttons -->
                                                        <div class="col-xs-3 form-col-container field-add-delete">
                                                            <p:commandLink styleClass="btn btn-default btn-sm bootstrap-button-tooltip" title="#{bundle.add}"
                                                                             actionListener="#{DataversePage.dataverse.addDataverseContact(valCount.index + 1)}">
                                                                <f:param name="SKIP_VALIDATION" value="true"/>
                                                                <h:outputText styleClass="glyphicon glyphicon-plus no-text"/>
                                                            </p:commandLink>
                                                            <p:commandLink styleClass="btn btn-default btn-sm bootstrap-button-tooltip" title="#{bundle.delete}"
                                                                             rendered="#{DataversePage.dataverse.dataverseContacts.size() > 1}"
                                                                             actionListener="#{DataversePage.dataverse.removeDataverseContact(valCount.index)}">
                                                                <f:param name="SKIP_VALIDATION" value="true"/>
                                                                <h:outputText styleClass="glyphicon glyphicon-minus no-text"/>
                                                            </p:commandLink>
                                                        </div>
                                                    </div>
                                                </ui:repeat>
                                            </div>
                                        </p:fragment>
                                    </div>
                                    <div class="col-md-6 form-group" jsf:rendered="#{DataversePage.getMetadataLanguages().size()>2}">
                                        <h:outputLabel for="dsMetadataLanguage" styleClass="control-label">
                                            #{bundle.metadataLanguage} 
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.metadatalanguage.title']}"></span>
                                        </h:outputLabel>
                                        <div class="form-col-container">
                                            <h:selectOneMenu id="dsMetadataLanguage" styleClass="form-control" value="#{DataversePage.dataverse.metadataLanguage}">
                                                <f:selectItems value="#{DataversePage.getMetadataLanguages()}" var="lang" itemLabel="#{lang.getValue()}" itemValue="#{lang.getKey()}"/>
                                            </h:selectOneMenu>
                                            <p:message for="dsMetadataLanguage" display="text"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6 form-group">
                                <div class="row">
                                    <div class="col-xs-12 form-group">
                                <h:outputLabel for="description" styleClass="control-label">
                                    #{bundle.description}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.description.title']}"></span>
                                </h:outputLabel>
                                <div class="form-col-container">
                                    <p class="help-block">
                                        <h:outputText value="#{bundle.htmlAllowedMsg}" escape="false"/>
                                    </p>
                                    <p:inputTextarea id="description" styleClass="form-control" value="#{DataversePage.dataverse.description}"
                                                    rows="6" cols="50"
                                                    autoResize="false">
                                    </p:inputTextarea>
                                    <p:message for="description" display="text"/>
                                </div>
                                </div>
                                    <div class="col-xs-12 form-group" jsf:rendered="#{DataversePage.getGuestbookEntryOptions().size()>2}">
                                        <h:outputLabel for="dsGuestbookEntryOption" styleClass="control-label">
                                            #{bundle.guestbookEntryOption} 
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.guestbookentryatrequest.title']}"></span>
                                        </h:outputLabel>
                                        <div class="form-col-container">
                                            <h:selectOneMenu id="dsGuestbookEntryOption" styleClass="form-control" value="#{DataversePage.dataverse.guestbookEntryAtRequest}">
                                                <f:selectItems value="#{DataversePage.getGuestbookEntryOptions()}" var="option" itemLabel="#{option.getValue()}" itemValue="#{option.getKey()}"/>
                                            </h:selectOneMenu>
                                            <p:message for="dsGuestbookEntryOption" display="text"/>
                                        </div>
                                    </div>
                                    <div class="col-xs-12 form-group" jsf:rendered="#{dataverseSession.user.superuser and DataversePage.getPidProviderOptions().size()>2}">
                                        <h:outputLabel for="dsPidProviderOption" styleClass="control-label">
                                            #{bundle.pidProviderOption} 
                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.pidProvider.title']}"></span>
                                        </h:outputLabel>
                                        <div class="form-col-container">
                                            <h:selectOneMenu id="dsPidProviderOption" styleClass="form-control" value="#{DataversePage.dataverse.pidGeneratorId}">
                                                <f:selectItems value="#{DataversePage.getPidProviderOptions()}" var="option" itemLabel="#{option.getValue()}" itemValue="#{option.getKey()}"/>
                                            </h:selectOneMenu>
                                            <p:message for="dsPidProviderOption" display="text"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <hr class="margin-top-half margin-bottom-half"/>
                        <!-- Metadata Panel -->
                        <p:panel id="optionBlock" styleClass="panelLayoutBlock padding-none margin-bottom-half" widgetVar="optionBlock">
                            <p:commandButton id="hiddenRefresh" value="back" style="display:none"
                                             actionListener="#{DataversePage.refresh}"
                                             update="@widgetVar(optionBlock)"/>
                            <div class="row">
                                <div class="col-sm-12 form-group padding-none">
                                    <div class="col-md-3 control-label highlightBold">#{bundle['dataverse.metadataElements']}</div>
                                    <div class="col-md-9">
                                        <p class="help-block">#{bundle['dataverse.metadataElements.tip']}</p>
                                        <h:outputLabel styleClass="metadata-blocks-default" for="metadataRoot" rendered="#{DataversePage.dataverse.owner != null}">
                                            <h:selectBooleanCheckbox id="metadataRoot" styleClass="metadata-blocks-default"
                                                                     value="#{DataversePage.inheritMetadataBlockFromParent}" onclick="updateMetadata(this);">
                                            </h:selectBooleanCheckbox>
                                            <h:outputFormat value="#{bundle['dataverse.metadataElements.from.tip']}">
                                                <f:param value="#{DataversePage.dataverse.metadataRootDataverseName}"/>
                                            </h:outputFormat>
                                        </h:outputLabel>
                                        <p:commandButton value="Direct" id="updateMetadataButton"
                                                         style="display:none"
                                                         update="@widgetVar(optionBlock)"
                                                         process="@this @widgetVar(optionBlock)"
                                                         actionListener="#{DataversePage.editMetadataBlocks(false)}">
                                        </p:commandButton>
                                        <p:commandButton value="Direct" id="resetToInherit"
                                                         style="display:none"
                                                         update="@widgetVar(optionBlock)" 
                                                         process="@this @widgetVar(optionBlock)"
                                                         action="#{DataversePage.resetToInherit()}">
                                        </p:commandButton>
                                        <ui:repeat value="#{DataversePage.allMetadataBlocks}" var="mdb">
                                            <div class="checkbox">
                                                <label for="#{mdb.idString}">
                                                    <input type="checkbox" jsf:itemValue="#{mdb}" id="#{mdb.idString}" jsf:value="#{mdb.selected}"
                                                           name="mdbSelectRequired" disabled="disabled" checked="checked" jsf:rendered="#{mdb.required and !DataversePage.inheritMetadataBlockFromParent}" />
                                                    <input type="checkbox" jsf:itemValue="#{mdb}" id="#{mdb.idString}" jsf:value="#{mdb.selected}"
                                                           name="mdbSelectRequiredInherited" disabled="disabled" jsf:rendered="#{DataversePage.inheritMetadataBlockFromParent}">
                                                        <p:ajax update="@widgetVar(optionBlock)" />
                                                    </input>
                                                    <input type="checkbox" jsf:itemValue="#{mdb}" id="#{mdb.idString}" jsf:value="#{mdb.selected}"
                                                           jsf:disabled="#{DataversePage.editInputLevel == true}"
                                                           name="mdbSelectOptional" jsf:rendered="#{!mdb.required and !DataversePage.inheritMetadataBlockFromParent}">
                                                        <p:ajax update="@widgetVar(optionBlock)" />
                                                    </input>
                                                    <h:outputText value="#{mdb.localeDisplayName} #{mdb.required ? bundle['dataverse.field.required']: ''}"
                                                                  styleClass="#{DataversePage.inheritMetadataBlockFromParent ? 'text-muted' : ''}"/>
                                                    <p:commandLink id="showDSFT" style="margin-left:1em;"
                                                                   update="@widgetVar(optionBlock)"
                                                                   process="@this"
                                                                   rendered="#{!mdb.showDatasetFieldTypes and (mdb.selected or mdb.required) and !DataversePage.openMetadataBlock and !DataversePage.inheritMetadataBlockFromParent}"
                                                                   actionListener="#{DataversePage.showDatasetFieldTypes(mdb.id)}">
                                                         <h:outputText value="#{bundle['dataverse.field.set.tip']}" />
                                                     </p:commandLink>
                                                     <p:commandLink id="viewDSFT" style="margin-left:1em;"
                                                                    update="@widgetVar(optionBlock)"
                                                                    process="@this"
                                                                    rendered="#{!mdb.showDatasetFieldTypes and (!mdb.selected or DataversePage.inheritMetadataBlockFromParent)   and !DataversePage.openMetadataBlock}"
                                                                    actionListener="#{DataversePage.showDatasetFieldTypes(mdb.id, false)}">
                                                         <h:outputText value="#{bundle['dataverse.field.set.view']}" />
                                                     </p:commandLink>
                                                </label>
                                            </div>
                                            <div id="metadataFieldOptionsPanel-Block" jsf:rendered="#{mdb.showDatasetFieldTypes}">
                                                <div class="panel panel-default">
                                                    <div id="metadataFieldOptionsPanel-Body" class="panel-body">
                                                        <table id="metadataFieldOptions" class="table table-striped">
                                                            <tbody>
                                                                <ui:repeat value="#{mdb.datasetFieldTypes}" var="dsft">
                                                                    <tr>
                                                                        <td>
                                                                            <p:selectBooleanCheckbox rendered="#{!dsft.hasParent}" value="#{dsft.include}" itemLabel="#{dsft.displayName}"
                                                                                                      onchange="scrollPos=document.getElementById('metadataFieldOptionsPanel-Body').scrollTop;#{DataversePage.updateInclude(mdb.id, dsft.id)}"
                                                                                                     disabled="#{(!dsft.hasParent and (dsft.hasRequiredChildren or dsft.required)) or DataversePage.editInputLevel == false }">
                                                                                <p:ajax update="@widgetVar(OptButton#{dsft.id}), @widgetVar(optionBlock)" />
                                                                            </p:selectBooleanCheckbox>
                                                                            <div class="checkbox child-field" jsf:rendered="#{dsft.hasParent}">
                                                                                <label>
                                                                                    <h:outputText value="#{dsft.displayName}"/>
                                                                                </label>
                                                                            </div>
                                                                        </td>
                                                                        <td>
                                                                            <p:selectOneRadio id="OptionsRadio#{dsft.id}" value="#{dsft.requiredDV}" widgetVar="OptButton#{dsft.id}" disabled ="#{DataversePage.editInputLevel == false}"
                                                                                              rendered="#{!dsft.hasChildren and (!dsft.required or (dsft.hasParent and !dsft.parentDatasetFieldType.required))}">
                                                                                <f:selectItems value="#{dsft.optionSelectItems}"/>
                                                                            </p:selectOneRadio>                                           
                                                                            <span class="text-muted" jsf:rendered="#{dsft.required and (!dsft.hasParent or dsft.parentDatasetFieldType.required)}">
                                                                                #{bundle['dataverse.field.requiredByDataverse']}
                                                                            </span>
                                                                        </td>
                                                                    </tr>
                                                                </ui:repeat>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                                <p:commandLink id="hideDSFT" styleClass="btn btn-default" 
                                                               process="@this @widgetVar(optionBlock)"
                                                               update="@widgetVar(optionBlock)" actionListener="#{DataversePage.hideDatasetFieldTypes(mdb.id)}" 
                                                               rendered="#{mdb.showDatasetFieldTypes}">
                                                    <h:outputText value="#{bundle.done}" />
                                                </p:commandLink>
                                            </div>
                                        </ui:repeat>
                                    </div>
                                </div>
                            </div>
                        </p:panel>
                        <!-- Facets Panel -->
                        <p:panel id="editFacets" styleClass="panelLayoutBlock padding-none" widgetVar="editFacets">
                            <div class="row">
                                <div class="col-sm-12 form-group padding-none">
                                    <div class="col-md-3 control-label highlightBold">#{bundle['dataverse.facetPickList.text']}</div>
                                    <div class="col-md-9">
                                        <p class="help-block">#{bundle['dataverse.facetPickList.tip']}</p>
                                        <h:outputLabel styleClass="metadata-blocks-default" for="facetsRoot" rendered="#{DataversePage.dataverse.owner != null}">
                                            <h:selectBooleanCheckbox id="facetsRoot" styleClass="facets-blocks-default"
                                                                     value="#{DataversePage.inheritFacetFromParent}">
                                                <p:ajax update="editFacets" listener="#{DataversePage.toggleFacetRoot}"/>
                                            </h:selectBooleanCheckbox>
                                            <h:outputFormat value="#{bundle['dataverse.facetPickList.facetsFromHost.text']}">
                                                <f:param value="#{DataversePage.dataverse.facetRootDataverseName}"/>
                                            </h:outputFormat>
                                        </h:outputLabel>
                                        <p:pickList id="facetPickListCreate" value="#{DataversePage.facets}" var="facet" converter="facetConverter"
                                                    itemLabel="#{facet.displayName}" itemValue="#{facet}"
                                                    disabled="#{!DataversePage.dataverse.facetRoot and DataversePage.dataverse.owner != null}"
                                                    style="margin-top:1em;">
                                            <f:facet name="sourceCaption">
                                                <p:selectOneMenu styleClass="facet-category-default"
                                                                 disabled="#{!DataversePage.dataverse.facetRoot and DataversePage.dataverse.owner != null}"
                                                                 value="#{DataversePage.facetMetadataBlockId}">
                                                    <f:selectItem itemLabel="#{bundle['dataverse.facetPickList.metadataBlockList.all']}" itemValue=""/>
                                                    <f:selectItems value="#{DataversePage.allMetadataBlocks}" var="mdb" itemLabel="#{mdb.localeDisplayName}" itemValue="#{mdb.id}" />
                                                    <p:ajax process="editFacets" update="editFacets" listener="#{DataversePage.changeFacetsMetadataBlock}"/>
                                                </p:selectOneMenu>
                                            </f:facet>
                                            <f:facet name="targetCaption">#{bundle['dataverse.selected']}</f:facet>
                                            <p:ajax event="transfer" listener="#{DataversePage.onFacetTransfer}" update="editFacets" />
                                            <f:passThroughAttribute name="aria-disabled" value="#{!DataversePage.dataverse.facetRoot and DataversePage.dataverse.owner != null}"/>
                                        </p:pickList>
                                    </div>
                                </div>
                            </div>
                        </p:panel>
                        <!-- Save / Cancel Button Panel -->
                        <div class="button-block">
                            <p:commandButton id="save" styleClass="btn btn-default" value="#{DataversePage.dataverse.id == null ? bundle.createDataverse : bundle.saveChanges}" action="#{DataversePage.save}" update=":dataverseForm, :messagePanel">
                                <f:ajax onerror="window.scrollTo(0, 0)" />
                            </p:commandButton>
                            <p:commandButton id="cancel" styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DataversePage.cancel}" rendered="#{DataversePage.dataverse.id != null}"/>
                            <p:button id="cancelCreate" styleClass="btn btn-link" value="#{bundle.cancel}" outcome="/dataverse.xhtml?alias=#{DataversePage.dataverse.owner.alias}" rendered="#{DataversePage.dataverse.id == null and DataversePage.ownerId != null}"/>
                        </div>
                    </ui:fragment>
                    <!-- END Edit Mode -->
                    <!-- View Mode / Description Panel -->
                    <ui:fragment rendered="#{empty DataversePage.editMode}">
                        <div id="actionButtonBlock" class="col-xs-12 button-block margin-bottom" jsf:rendered="#{!widgetWrapper.widgetView}">
                            <div class="row">
                                <!-- Metrics for Root Dataverse -->
                                <div id="metrics-block1" class="col-xs-4" jsf:rendered="#{DataversePage.isRootDataverse() and !settingsWrapper.rsyncOnly}">
                                    <div id="metrics-label" class="col-xs-4 small text-center">
                                        <h:outputLink value="#{settingsWrapper.metricsUrl}" target="_blank" title="#{bundle['metrics.title.tip']}" rendered="#{settingsWrapper.metricsUrl != null}">
                                            <span class="glyphicon glyphicon-stats"/> #{bundle['metrics.title']}
                                        </h:outputLink>
                                        <ui:fragment rendered="#{settingsWrapper.metricsUrl == null}">
                                            <span class="glyphicon glyphicon-stats"/> #{bundle['metrics.title']}
                                        </ui:fragment>
                                    </div>
                                    <div id="metrics-content" class="col-xs-8 small text-center">
                                        <h:outputFormat styleClass="metrics-downloads" value="{0} #{bundle['metrics.downloads']}">
                                            <f:param value="#{guestbookResponseServiceBean.getTotalDownloadCount()}"/>
                                        </h:outputFormat>
                                    </div>
                                </div>
                                <!-- END: Metrics for Root Dataverse-->
                                <!-- ActionButtonBlock -->
                                <div class="#{DataversePage.isRootDataverse() ? 'col-xs-8' : 'col-xs-12'} text-right padding-none">
                                    <!-- Email/Link/Share Button Group -->
                                    <div class="btn-group" role="group">
                                        <p:commandLink type="button" styleClass="text-button btn-contact bootstrap-button-tooltip" title="#{bundle['dataverse.contact']}"
                                                       update=":contactDialog" oncomplete="PF('contactForm').show()" actionListener="#{sendFeedbackDialog.initUserInput}">
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                            <f:param name="DO_VALIDATION" value="false"/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{DataversePage.dataverse}"/>
                                                <span class="glyphicon glyphicon-envelope"/> #{bundle['contact.contact']}
                                        </p:commandLink>
                                        <p:commandLink type="button" styleClass="text-button btn-share bootstrap-button-tooltip"
                                           title="#{bundle['dataverse.share.dataverseShare']}"
                                           oncomplete="PF('shareDialog').show();sharrre();">
                                            <span class="glyphicon glyphicon-share"/> #{bundle['share']}
                                        </p:commandLink>
                                    </div>
                                    <!-- END: Email/Link/Share Button Group -->
                                    <!-- Edit/Publish Button Group -->
                                    <div class="btn-group" jsf:rendered="#{dataverseSession.user.authenticated and
                                                             (permissionsWrapper.canIssueUpdateDataverseCommand(DataversePage.dataverse)
                                                             or permissionsWrapper.canIssuePublishDataverseCommand(DataversePage.dataverse))}">
                                            <!-- Publish Button -->
                                            <ui:fragment rendered="#{permissionsWrapper.canIssuePublishDataverseCommand(DataversePage.dataverse)}">
                                                <button type="button" class="btn btn-default btn-access" onclick="PF('confirmation').show()"
                                                        jsf:rendered="#{!DataversePage.dataverse.released and (empty DataversePage.dataverse.owner or DataversePage.dataverse.owner.released)}">
                                                    <span class="glyphicon glyphicon-globe"/> #{bundle['dataverse.publish.btn']}
                                                </button>
                                                <button type="button" class="btn btn-default btn-access" onclick="PF('mayNotRelease').show()"
                                                        jsf:rendered="#{!DataversePage.dataverse.released and (!empty DataversePage.dataverse.owner and !DataversePage.dataverse.owner.released)}">
                                                    <span class="glyphicon glyphicon-globe"/> #{bundle['dataverse.publish.btn']}
                                                </button>
                                            </ui:fragment>
                                            <!-- END: Publish Button -->
                                            <ui:fragment rendered="#{DataversePage.showLinkingPopup()}">
                                            <div class="btn-group" >
                                                <button type="button" class="btn btn-default btn-access dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                                    <span class="glyphicon glyphicon-link"/> #{bundle['link']} <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu pull-right text-left">
                                                    <li class="#{DataversePage.dataverse.owner != null ? '' : 'disabled'}">
                                                        <p:commandLink action="#{DataversePage.setupLinkingPopup('link')}"
                                                                       oncomplete="PF('linkDataverseForm').show()"
                                                                       update=":linkDataverseForm"
                                                                       >
                                                            #{bundle['dataverse.link']}
                                                        </p:commandLink>
                                                    </li>
                                                    <li class="#{SearchIncludeFragment.mode == 'search' ? '' : 'disabled'}">
                                                        <p:commandLink action="#{DataversePage.setupLinkingPopup('savedSearch')}"
                                                                       oncomplete="PF('linkDataverseForm').show()"
                                                                       update=":linkDataverseForm"
                                                                       >
                                                            #{bundle['dataverse.savedsearch.link']}
                                                        </p:commandLink>
                                                    </li>
                                                </ul>
                                            </div>
                                            </ui:fragment>
                                            <!-- Edit Button -->
                                            <div class="btn-group" jsf:rendered="#{permissionsWrapper.canIssueUpdateDataverseCommand(DataversePage.dataverse)}">
                                                <button type="button" class="btn btn-default btn-access dropdown-toggle" data-toggle="dropdown">
                                                    <span class="glyphicon glyphicon-pencil"/> #{bundle['dataverse.edit']} <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu pull-right text-left">
                                                    <li>
                                                        <div id="dataverse-info-dropdown">
                                                            <div class="dataverse-info-logo-icon">
                                                                <span class="icon-dataverse text-brand"></span>
                                                            </div>
                                                            <div class="dataverse-info-general">
                                                                <div><h:outputText value="#{DataversePage.dataverse.name}" styleClass="highlightBold"/> <h:outputText value=" (#{DataversePage.dataverse.affiliation})" styleClass="text-muted" rendered="#{!empty DataversePage.dataverse.affiliation}"/></div>
                                                                <div class="text-muted">#{DataversePage.dataverse.alias}</div>
                                                            </div>
                                                        </div>
                                                    </li>
                                                    <li class="divider" role="presentation"></li>
                                                    <li>
                                                        <p:commandLink id="editInfo" actionListener="#{DataversePage.edit('INFO')}" update=":dataverseForm,:searchResults,:messagePanel">
                                                            <h:outputText value="#{bundle['dataverse.option.generalInfo']}" />
                                                        </p:commandLink>
                                                    </li>
                                                    <li>
                                                        <h:link outcome="ThemeAndWidgets" id="themeWidgetsOpts">
                                                            <f:param name="id" value="#{DataversePage.dataverse.id}" />
                                                            <h:outputText value="#{bundle['dataverse.option.themeAndWidgets']}" />
                                                        </h:link>
                                                    </li>
                                                    <ui:fragment rendered="#{permissionsWrapper.canManagePermissions(DataversePage.dataverse)}">
                                                        <li>
                                                            <h:link id="managePermissions" styleClass="ui-commandlink ui-widget" outcome="permissions-manage">
                                                                <h:outputText value="#{bundle['dataverse.option.permissions']}" />
                                                                <f:param name="id" value="#{DataversePage.dataverse.id}" />
                                                            </h:link>
                                                        </li>
                                                    </ui:fragment>
                                                    <ui:fragment rendered="#{permissionsWrapper.canManagePermissions(DataversePage.dataverse)}">
                                                        <li>
                                                            <h:link id="manageGroups" styleClass="ui-commandlink ui-widget" outcome="manage-groups">
                                                                <h:outputText value="#{bundle['dataverse.option.dataverseGroups']}" />
                                                                <f:param name="dataverseId" value="#{DataversePage.dataverse.id}" />
                                                            </h:link>
                                                        </li>
                                                    </ui:fragment>
                                                    <li>
                                                        <h:link id="manageTemplates" styleClass="ui-commandlink ui-widget" outcome="manage-templates">
                                                            <h:outputText value="#{bundle['dataverse.option.datasetTemplates']}" />
                                                            <f:param name="dataverseId" value="#{DataversePage.dataverse.id}" />
                                                        </h:link>
                                                    </li>
                                                    <li jsf:rendered="#{!settingsWrapper.rsyncOnly}">
                                                        <h:link id="manageGuestbooks" styleClass="ui-commandlink ui-widget" outcome="manage-guestbooks">
                                                            <h:outputText value="#{bundle['dataverse.option.datasetGuestbooks']}" />
                                                            <f:param name="dataverseId" value="#{DataversePage.dataverse.id}" />
                                                        </h:link>
                                                    </li>
                                                    <li>
                                                        <p:commandLink id="browseOpts" actionListener="#{DataversePage.edit('FEATURED')}" oncomplete="PF('browseOptsForm').show()"
                                                                       update="dataverseForm:browseOptsForm">
                                                            <h:outputText value="#{bundle['dataverse.option.featuredDataverse']}" />
                                                        </p:commandLink>
                                                    </li>
                                                    <ui:fragment rendered="#{DataversePage.isEmptyDataverse() and !(DataversePage.dataverse.owner == null)
                                                                             and permissionsWrapper.canIssueDeleteDataverseCommand(DataversePage.dataverse)}">
                                                        <li class="divider"></li>
                                                        <li>
                                                            <p:commandLink id="deleteDataset" onclick="PF('deleteConfirmation').show()">
                                                                <h:outputText value="#{bundle['dataverse.option.deleteDataverse']}" />
                                                            </p:commandLink>
                                                        </li>
                                                    </ui:fragment>
                                                </ul>
                                            </div>
                                            <!-- END: Edit Button -->
                                    </div>
                                    <!-- END: Edit/Publish Button Group -->
                                </div>
                            </div>
                            <!-- END: ActionButtonBlock -->
                        </div>
                        <ui:fragment rendered="#{SearchIncludeFragment.filterQueries.size() == 0 and SearchIncludeFragment.mode != SearchIncludeFragment.searchModeString}">
                            <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                            <div class="row margin-bottom" jsf:rendered="#{!empty DataversePage.dataverse.description and !widgetWrapper.widgetView}">
                                <div id="dataverseDesc" class="col-xs-12">
                                   <h:outputText value="#{MarkupChecker:sanitizeBasicHTML(DataversePage.dataverse.description)}" escape="false"/>
                                </div>
                            </div>
                            <!-- Featured Dataverses Carousel -->
                            <div id="carouselBlocksWrapper" class="row" jsf:rendered="#{!empty DataversePage.carouselFeaturedDataverses}">
                                <div id="featuredDataversesBlock" class="col-xs-12">
                                    <div class="customNavigation">
                                        <a class="btn prev1" title="#{bundle['dataverse.page.pre']}"><span class="glyphicon glyphicon-chevron-left"/></a>
                                    </div>
                                    <div id="featuredDataversesList" class="owl-carousel owl-theme">
                                        <ui:repeat value="#{DataversePage.carouselFeaturedDataverses}" var="dv" varStatus="status">
                                            <div class="item" style="vertical-align:middle;">
                                                <c:set var="dvFeatUrl" value="/dataverse/#{dv.alias}"/>
                                                <a href="#{widgetWrapper.wrapURL(dvFeatUrl)}">
                                                    <img src="/logos/#{dv.logoOwnerId}/#{dv.dataverseTheme.logo}" alt="#{of:format1(bundle['alt.logo'], dv.name)}" jsf:rendered="#{!empty dv.dataverseTheme.logo and empty dv.dataverseTheme.logoThumbnail}"/>
                                                    <img src="/logos/#{dv.logoOwnerId}/#{dv.dataverseTheme.logoThumbnail}" alt="#{of:format1(bundle['alt.logo'], dv.name)}" jsf:rendered="#{!empty dv.dataverseTheme.logoThumbnail}"/>
                                                    <span class="icon-dataverse" jsf:rendered="#{empty dv.dataverseTheme.logo and empty dv.dataverseTheme.logoThumbnail}"></span>
                                                    <h:outputText styleClass="show" value="#{dv.name}"/>
                                                </a>
                                            </div>
                                        </ui:repeat>
                                    </div>
                                    <div class="customNavigation">
                                        <a class="btn next1" title="#{bundle['dataverse.page.next']}"><span class="glyphicon glyphicon-chevron-right"/></a>
                                    </div>
                                </div>
                            </div>
                            <!-- END: Featured Dataverses Carousel -->
                        </ui:fragment>
                    </ui:fragment>
                    <!-- POPUPS -->
                    <!-- Featured Dataverses Popup -->
                    <p:dialog id="browseOptsForm" header="#{bundle['dataverse.option.featuredDataverse']}" widgetVar="browseOptsForm" modal="true">
                        <ui:fragment rendered="#{!empty DataversePage.featuredDataverses.source or !empty DataversePage.featuredDataverses.target}">
                            <p:focus for="featuredDataverseList"/>
                            <div class="form-group">
                                <p class="help-block">#{bundle['dataverse.selectToFeature']}</p>
                                <p:pickList id="featuredDataverseList" value="#{DataversePage.featuredDataverses}" var="featureddataverse"
                                            itemLabel="#{featureddataverse.name}"
                                            itemValue="#{featureddataverse}" converter="dataverseConverter"
                                            showSourceFilter="true" showTargetFilter="true" />
                            </div>
                            <div class="button-block">
                                <p:commandButton styleClass="btn btn-default" value="#{bundle.saveChanges}" action="#{DataversePage.save}"/>
                                <button class="btn btn-link" onclick="PF('browseOptsForm').hide();" type="button">                              
                                    #{bundle.cancel}
                                </button>
                            </div>
                        </ui:fragment>
                        <ui:fragment rendered="#{empty DataversePage.featuredDataverses.source and empty DataversePage.featuredDataverses.target}">
                            <p class="text-danger">
                                <span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataverse.nopublished.tip']}
                            </p>
                            <div class="button-block">
                                <button class="btn btn-default" onclick="PF('browseOptsForm').hide();" type="button">                              
                                    #{bundle.close}
                                </button>
                            </div>
                        </ui:fragment>
                    </p:dialog>
                    <!-- Publish Confirmation Popup -->
                    <p:dialog id="publishDvConfirm" header="#{bundle['dataverse.publish.header']}" widgetVar="confirmation" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataverse.publish.tip']}
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('confirmation').hide()" action="#{DataversePage.releaseDataverse}"/>
                            <button class="btn btn-link" onclick="PF('confirmation').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="mayNotRelease" header="#{bundle['dataverse.publish.header']}" widgetVar="mayNotRelease" modal="true">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataverse.publish.failed.tip']}
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('mayNotRelease').hide();" type="button">                              
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteDvConfirm" header="#{bundle['dataverse.delete']}" widgetVar="deleteConfirmation" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataverse.delete.tip']}
                        </p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('deleteConfirmation').hide()" action="#{DataversePage.deleteDataverse}"/>
                            <button class="btn btn-link" onclick="PF('deleteConfirmation').hide();" type="button">                              
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                </h:form>
                <!-- Search/Browse Facets Panel -->
                <p:fragment id="searchResults">
                    <ui:fragment rendered="#{empty DataversePage.editMode}">
                        <ui:include src="search-include-fragment.xhtml"/>
                    </ui:fragment>
                </p:fragment>
                <!-- END Search/Browse Facets Panel -->
                <!-- POPUPS -->
                    <p:dialog id="shareDialog" header="#{bundle['dataverse.share.dataverseShare']}" widgetVar="shareDialog" modal="true">
                        <h:form styleClass="form-horizontal"> 
                        <p class="help-block">#{bundle['dataverse.share.dataverseShare.tip']}</p>
                        <div id="sharrre-widget" data-url="#{settingsWrapper.dataverseSiteUrl}/dataverse/#{DataversePage.dataverse.alias}" data-text="#{bundle['dataverse.share.dataverseShare.shareText']}"></div>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('shareDialog').hide()" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                        </h:form>
                    </p:dialog>
                    <!-- Link Dataverse Popup -->
                    <p:dialog id="linkDataverseForm" header="#{DataversePage.linkMode == 'SAVEDSEARCH' ? bundle['dataverse.savedsearch.link'] : bundle['dataverse.link']}" widgetVar="linkDataverseForm" modal="true">
                        <h:form styleClass="form-horizontal"> 
                            <ui:fragment rendered="#{DataversePage.dataversesForLinking.size() > 1}">
                                <p:focus for="dvNameSelect"/>
                                <ui:fragment rendered="#{DataversePage.linkMode == 'LINKDATAVERSE'}">
                                    <p class="help-block">#{bundle['dataverse.link.dataverse.choose']}</p>
                                </ui:fragment>
                                <ui:fragment rendered="#{DataversePage.linkMode == 'SAVEDSEARCH'}">
                                    <p class="help-block">#{bundle['dataverse.savedsearch.dataverse.choose']}</p>
                                </ui:fragment>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">
                                        <h:outputFormat value="#{bundle['dataverse.link.yourDataverses']}">
                                            <f:param value="#{DataversePage.dataversesForLinking.size()}"/>
                                        </h:outputFormat>
                                    </label>
                                    <div class="col-sm-7">
                                        <h:selectOneMenu id="dvNameSelect" styleClass="form-control" value="#{DataversePage.linkingDataverseId}">
                                            <f:selectItems value="#{DataversePage.linkingDVSelectItems}" />
                                        </h:selectOneMenu>
                                        <ui:remove>
                                            <p:autoComplete id="dvName"
                                                            value="#{DataversePage.dataversesForLinking}"
                                                            queryDelay="1000"
                                                            var="u"
                                                            itemLabel="#{u.id}"
                                                            itemValue="#{u.id}">
                                                <f:facet name="itemtip">
                                                    <div>
                                                        <strong>#{u.id}</strong><br/>
                                                        <em>#{u.affiliation}</em>
                                                    </div>
                                                </f:facet>
                                            </p:autoComplete>
                                        </ui:remove>
                                    </div>
                                </div>
                                <ui:fragment rendered="#{DataversePage.linkMode == 'SAVEDSEARCH'}">
                                    <div class="form-group" jsf:rendered="#{!empty SearchIncludeFragment.query}">
                                        <label class="col-sm-4 control-label">
                                         #{bundle['dataverse.savedsearch.searchquery']}
                                        </label>
                                        <div class="col-sm-7">
                                            <p class="form-control-static">
                                            #{SearchIncludeFragment.query.toString()}
                                            </p>
                                        </div>
                                    </div>
                                    <div class="form-group" jsf:rendered="#{!empty SearchIncludeFragment.filterQueriesDebug}">
                                        <label class="col-sm-4 control-label">
                                         #{bundle['dataverse.savedsearch.filterQueries']}
                                        </label>
                                        <div class="col-sm-7">
                                            <ui:repeat value="#{SearchIncludeFragment.filterQueriesDebug}" var="fq">
                                                <p class="form-control-static"><h:outputText value="#{fq}"/></p>
                                            </ui:repeat>
                                        </div>
                                    </div>
                                </ui:fragment>
                                <div class="button-block">
                                    <p:commandButton styleClass="btn btn-default" value="#{bundle['dataverse.link.save']}" action="#{DataversePage.saveLinkedDataverse}"
                                                     rendered="#{DataversePage.linkMode == 'LINKDATAVERSE'}"/>
                                <p:commandButton styleClass="btn btn-default" value="#{bundle['dataverse.savedsearch.save']}" action="#{DataversePage.saveSavedSearch}"
                                                     rendered="#{DataversePage.linkMode == 'SAVEDSEARCH'}"/>
                                    <button class="btn btn-link" onclick="PF('linkDataverseForm').hide();" type="button">                              
                                    #{bundle.cancel}
                                    </button>
                                </div>
                            </ui:fragment>

                            <ui:fragment rendered="#{DataversePage.dataversesForLinking.size() == 1}">
                                <p class="help-block">#{bundle['dataverse.link.no.choice']}</p>
                                <div class="form-horizontal">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">
                                            <h:outputFormat value="#{bundle['dataverse.link.yourDataverses']}">
                                                <f:param value="#{DataversePage.dataversesForLinking.size()}"/>
                                            </h:outputFormat>
                                        </label>
                                        <div class="col-sm-7">
                                            <p class="form-control-static">#{DataversePage.linkingDataverse.displayName}</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="button-block">
                                    <p:commandButton styleClass="btn btn-default" value="#{bundle['dataverse.link.save']}" onclick="PF('linkDataverseForm').hide()" actionListener="#{DataversePage.saveLinkedDataverse()}"/>
                                    <button class="btn btn-link" onclick="PF('linkDataverseForm').hide();" type="button">                              
                                    #{bundle.cancel}
                                    </button>
                                </div>
                            </ui:fragment>
                            <ui:fragment rendered="#{DataversePage.dataversesForLinking.size() == 0}">
                                <p class="text-danger">
                                    <span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataverse.link.no.linkable']}
                                </p>
                                <div class="button-block">
                                    <button class="btn btn-default" onclick="PF('linkDataverseForm').hide();" type="button">                              
                                    #{bundle.close}
                                    </button>
                                </div>
                            </ui:fragment>
                        </h:form>
                    </p:dialog>
                <!-- Metadata Resest Modifications Popup -->
                <p:dialog id="resetModifications" header="#{bundle['dataverse.resetModifications']}" widgetVar="resetModifications" modal="true" closable="false">
                    <h:form styleClass="form-horizontal">
                    <p class="text-warning">
                        <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataverse.resetModifications.text']}
                    </p>
                    <div class="button-block">
                        <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="check();PF('resetModifications').hide()"/>
                        <button class="btn btn-link" onclick="uncheck();PF('resetModifications').hide()" type="button">                              
                            #{bundle.cancel}
                        </button>
                    </div>
                    </h:form>
                </p:dialog>
                <c:set var="descriptionText" value="#{bundle.description}" />
                <script>
                    //<![CDATA[
                    var scrollPos=0;
                    $(document).ready(function () {
                        initCarousel();
                        popoverHTML('#{bundle.htmlAllowedTitle}','#{bundle.htmlAllowedTags}');
                        summarizeDesc();
                    });
                    function initCarousel() {
                        var owl1 = $("#featuredDataversesList");
                        owl1.owlCarousel({
                            pagination: false,
                            navigation: false,
                            items: 4, //10 items above 1000px browser width
                            itemsDesktop: [1140, 4], //5 items between 1000px and 901px
                            itemsDesktopSmall: [940, 3], // betweem 900px and 601px
                            itemsTablet: [720, 2], //2 items between 600 and 0
                            itemsMobile: false // itemsMobile disabled - inherit from itemsTablet option
                        });
                        if (owl1.find('div.owl-item').length > 4) {
                            // Custom Navigation Events
                            $(".next1").click(function () {
                                owl1.trigger('owl.next');
                            });
                            $(".prev1").click(function () {
                                owl1.trigger('owl.prev');
                            });
                        } else {
                            $("#featuredDataversesBlock .customNavigation a.btn").hide();
                        }
                        $('#featuredDataversesList .item').matchHeight();
                    }
                    function summarizeDesc() {
                        // truncate summary description, contentTruncate function in dv_rebind_bootstrap_ui.js
                        // add id to pass as selector param
                        var descId = 'dataverseDesc';
                        // add metadata dynamic label text, tooltip text from bundle as param
                        var truncMoreBtn = '#{of:format1(bundle.truncateMoreBtn, descriptionText)}';
                        var truncMoreTip = '#{of:format1(bundle.truncateMoreTip, descriptionText)}';
                        var truncLessBtn = '#{of:format1(bundle.truncateLessBtn, descriptionText)}';
                        var truncLessTip = '#{of:format1(bundle.truncateLessTip, descriptionText)}';
                        // pass bundle text variables as params to function
                        contentTruncate(descId, truncMoreBtn, truncMoreTip, truncLessBtn, truncLessTip);
                    }
                    function callOnError(){
                        window.scrollTo(0, 0);
                    }
                    function updateInclude() {
                        $('button[id$="hiddenRefresh"]').trigger('click');
                    }
                    function scrollAfterUpdate() {
                        document.getElementById('metadataFieldOptionsPanel-Body').scrollTop = scrollPos;
                    }
                    
                    function updateMetadata(checkbox) {
                        var checked = checkbox.checked;
                        if (checked === false){
                            $('button[id$="updateMetadataButton"]').trigger('click');
                        } else {
                            PF('resetModifications').show();
                        }
                    }
                    function check() {
                        $('button[id$="resetToInherit"]').trigger('click');
                    }
                    function uncheck() {
                        $('input:checkbox[id$="metadataRoot"]').prop('checked', false);
                    }
                    function updateOwnerDataverse() {
                        $('button[id$="updateOwnerDataverse"]').trigger('click');
                    }
                    //]]>                                     
                </script>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
